define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'shop/contract/index',
                    add_url: 'shop/contract/add',
                    edit_url: 'shop/contract/edit',
                    del_url: 'shop/contract/del',
                    multi_url: 'shop/contract/multi',
                    table: 'shop_contract',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order_id', title: __('Order_id')},
                        {field: 'userid', title: __('Userid111')},
                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1')}, formatter: Table.api.formatter.normal},
                        // {field: 'id_card', title: __('Id_card')},
                        {field: 'student_name', title: __('Student_name')},
                        {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"2":__('Gender 2')}, formatter: Table.api.formatter.normal},
                        {field: 'edition', title: __('Edition'), searchList: {"1":__('Edition 1'),"2":__('Edition 2'),"3":__('Edition 3'),"4":__('Edition 4'),"5":__('Edition 6'),"6":__('Edition 6'),"7":__('Edition 7')}, formatter: Table.api.formatter.normal},
                        {field: 'parent_name', title: __('Parent_name')},
                        {field: 'phone', title: __('Phone')},
                        // {field: 'tel', title: __('Tel')},
                        {field: 'grade', title: __('Grade')},
                        {field: 'last_exam', title: __('Last_exam')},
                        {field: 'province_text', title: __('Province')},
                        {field: 'city_text', title: __('City')},
                        {field: 'area_text', title: __('Area')},
                        // {field: 'address', title: __('Address')},
                        // {field: 'email', title: __('Email')},
                        // {field: 'code', title: __('Code')},
                        {field: 'closing_date', title: __('Closing_date'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,datetimeFormat: 'YYYY-MM-DD'},
                       {field: 'sign_date', title: __('Sign_date'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,datetimeFormat: 'YYYY-MM-DD'},
                        {field: 'status', title: __('Statuss'), searchList: {"1":__('Statuss 1'),"2":__('Statuss 2')},  formatter: Table.api.formatter.normal},
                        // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});